package org.bonorsoft.modules.control.mapper;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bonorsoft.modules.control.entity.Label;
import org.bonorsoft.modules.control.entity.Population;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.bonorsoft.modules.control.vo.PopulationVo;

import java.util.List;

/**
 * @Description: 实有人口信息
 * @Author: WilliamYe
 * @Date:   2021-03-04
 * @Version: V1.0
 */
public interface PopulationMapper extends BaseMapper<Population> {

    @Select("SELECT rkbm,dzbm,dzmc,syrkdzzdjlxdm,syrkgllbdm,gmsfhm,xm,ywsfzh,cyzjdm,zjhm,sfjwry,wwx,wwm,xbdm,mzdm,csrq,rhflbz,lxdh,hjd_dzbm,hjd,bq,zdrybz,zdrylb,sjly,djdw_gajgjgdm,djdw_gajgmc,djr_zh,djr_xm,djsj,gxr_zh,gxbm,gxsj,sssj,ssfxj,sspcs,sszrq,hlbm,hlsj,hlr,hlbz,zxdhzb,zxdzzb,hh,yhzgx,yzj,sfysljzz,jwrylx,bz,zdrylbmc,hlwshr,hlwshsj,nwbz,in_time,hz_hjd,ssds,ssjd,sssq,sswg,zxsj,zxzh,zxsjbz,hszt,spzt,tszt,spr,spsj,sssqjwwg_dzbm,syrkhsjg,qwd_gjhdqdm,qwd_ssxqdm,qwd_qhnxz,gjhdqdm,zxyy,sssqjcwg_dzbm,ssjlxxq_dzbm," +
            "(select photo_path from police_photo where police_photo.id = ybss_ry_syrk.rkbm) as photo " +
            "FROM ybss_ry_syrk ${ew.customSqlSegment}")
    IPage<PopulationVo> paging(Page<Population> page, @Param(Constants.WRAPPER) QueryWrapper<Population> queryWrapper);

    @Select("SELECT rkbm,dzbm,dzmc,syrkdzzdjlxdm,syrkgllbdm,gmsfhm,xm,ywsfzh,cyzjdm,zjhm,sfjwry,wwx,wwm,xbdm,mzdm,csrq,rhflbz,lxdh,hjd_dzbm,hjd,bq,zdrybz,zdrylb,sjly,djdw_gajgjgdm,djdw_gajgmc,djr_zh,djr_xm,djsj,gxr_zh,gxbm,gxsj,sssj,ssfxj,sspcs,sszrq,hlbm,hlsj,hlr,hlbz,zxdhzb,zxdzzb,hh,yhzgx,yzj,sfysljzz,jwrylx,bz,zdrylbmc,hlwshr,hlwshsj,nwbz,in_time,hz_hjd,ssds,ssjd,sssq,sswg,zxsj,zxzh,zxsjbz,hszt,spzt,tszt,spr,spsj,sssqjwwg_dzbm,syrkhsjg,qwd_gjhdqdm,qwd_ssxqdm,qwd_qhnxz,gjhdqdm,zxyy,sssqjcwg_dzbm,ssjlxxq_dzbm," +
            "(select photo_path from police_photo where police_photo.id = ybss_ry_syrk.rkbm) as photo " +
            "FROM ybss_ry_syrk ${ew.customSqlSegment}")
    List<PopulationVo> listing(@Param(Constants.WRAPPER) QueryWrapper<Population> queryWrapper);

    int saveBatchPhoto(List<PopulationVo> list);

    @Select("select " +
            "l.label_id, l.label_name " +
            "from " +
            "police_label l " +
            "left join ybss_ry_syrk r " +
            "on r.bq like concat('%',concat(l.label_id,'%')) " +
            "where " +
            "r.rkbm = #{id}")
    List<Label> getLabel(String id);

}
